const state = {
  orderList: [],
  orderFresh: false
}

const mutations = {
  ADD_ORDER_LIST: (state, tableOrder) => {
    state.orderList.push(tableOrder)
  },
  CLEAR_ORDER_LIST: (state) => {
    state.orderList = []
  },
  SET_ORDER_FRESH: (state, isFresh) => {
    state.orderFresh = isFresh
  }
}
const actions = {
  addOrderList({ commit }, tableOrder) {
    commit('ADD_ORDER_LIST', tableOrder)
    commit('SET_ORDER_FRESH', true)
  },
  clearOrderList({ commit }) {
    commit('CLEAR_ORDER_LIST')
  },
  setOrderFresh({ commit }, isFresh) {
    commit('SET_ORDER_FRESH', isFresh)
  }
}

export default {
  namespaced: true,
  state,
  mutations,
  actions
}
